//
//  LWTextViewToolBar.m
//  1.28  weibo
//
//  Created by mac on 15/2/12.
//  Copyright (c) 2015年 mac. All rights reserved.
//

#import "LWTextViewToolBar.h"

@implementation LWTextViewToolBar

- (instancetype)initWithFrame:(CGRect)frame{

    self = [super initWithFrame:frame];
    [self upDate];
    return self;
}

- (id)initWithCoder:(NSCoder *)coder{

    self = [super initWithCoder:coder];
    [self upDate];
    return self;
}
- (void)upDate{

    [self setUpButtonWithImage:@"compose_toolbar_picture" highlightImage:@"compose_toolbar_picture_highlighted"];
    [self setUpButtonWithImage:@"compose_emoticonbutton_background" highlightImage:@"compose_emoticonbutton_background_highlighted"];
    [self setUpButtonWithImage:@"compose_trendbutton_background" highlightImage:@"compose_trendbutton_background_highlighted"];
    [self setUpButtonWithImage:@"compose_mentionbutton_background" highlightImage:@"compose_mentionbutton_background_highlighted"];
    [self setUpButtonWithImage:@"compose_trendbutton_background" highlightImage:@"compose_trendbutton_background_highlighted"];
}
- (void)setUpButtonWithImage:(NSString *)image highlightImage:(NSString *)highlightImage{

    UIButton *btn = [[UIButton alloc] init];
    [btn setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    [btn setImage:[UIImage imageNamed:highlightImage] forState:UIControlStateHighlighted];
    [btn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:btn];
    
}
- (void)btnClick:(UIButton *)btn{

}
- (void)layoutSubviews{
    [super layoutSubviews];
    NSInteger count = self.subviews.count;
    CGFloat width = self.width / count;
    for (int i = 0; i < count; i++) {
        UIButton *btn = self.subviews[i];
        btn.width = width;
        btn.height = self.height;
        btn.x = i * width;
        btn.y = 0;
}
    
}

@end
